//
//  VCView.m
//  XQChartDemo
//
//  Created by xq on 2024/6/15.
//

#import "VCView.h"
#import <Masonry/Masonry.h>

@interface VCView ()

@end

@implementation VCView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 初始化
        self.chartView = [XQChartView new];
        [self addSubview:self.chartView];
        
        self.xSlider = [UISlider new];
        [self addSubview:self.xSlider];
        self.xAddBtn = [UIButton new];
        [self addSubview:self.xAddBtn];
        self.xRemoveBtn = [UIButton new];
        [self addSubview:self.xRemoveBtn];
        
        self.ySlider = [UISlider new];
        [self addSubview:self.ySlider];
        self.yAddBtn = [UIButton new];
        [self addSubview:self.yAddBtn];
        self.yRemoveBtn = [UIButton new];
        [self addSubview:self.yRemoveBtn];
        
        self.pointAddBtn = [UIButton new];
        [self addSubview:self.pointAddBtn];
        self.pointRemoveBtn = [UIButton new];
        [self addSubview:self.pointRemoveBtn];
        
        self.selectPreBtn = [UIButton new];
        [self addSubview:self.selectPreBtn];
        self.selectNextBtn = [UIButton new];
        [self addSubview:self.selectNextBtn];
        
        self.okBtn = [UIButton new];
        [self addSubview:self.okBtn];
        self.clearBtn = [UIButton new];
        [self addSubview:self.clearBtn];
        
        // 布局
        [self.chartView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(20);
            make.left.equalTo(self).offset(12);
            make.right.equalTo(self).offset(-12);
//            make.height.mas_equalTo(150);
            make.height.mas_equalTo(300);
//            make.height.mas_equalTo(700);
        }];
        
        [self.xSlider mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.chartView.mas_bottom).offset(20);
            make.left.equalTo(self.chartView);
            make.right.equalTo(self.chartView);
        }];
        
        [self.xAddBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.xSlider.mas_bottom).offset(20);
            make.left.equalTo(self.chartView);
        }];
        
        [self.xRemoveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.xAddBtn);
            make.left.equalTo(self.xAddBtn.mas_right).offset(20);
        }];
        
        [self.ySlider mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.xAddBtn.mas_bottom).offset(30);
            make.left.equalTo(self.xSlider);
            make.right.equalTo(self.xSlider);
        }];
        
        [self.yAddBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.ySlider.mas_bottom).offset(20);
            make.left.equalTo(self.xSlider);
        }];
        
        [self.yRemoveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.yAddBtn);
            make.left.equalTo(self.yAddBtn.mas_right).offset(20);
        }];
        
        [self.pointAddBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.yAddBtn.mas_bottom).offset(30);
            make.left.equalTo(self.ySlider);
        }];
        
        [self.pointRemoveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.pointAddBtn);
            make.left.equalTo(self.pointAddBtn.mas_right).offset(20);
        }];
        
        [self.selectPreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.pointAddBtn);
            make.left.equalTo(self.pointRemoveBtn.mas_right).offset(20);
        }];
        
        [self.selectNextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.pointAddBtn);
            make.left.equalTo(self.selectPreBtn.mas_right).offset(20);
        }];
        
        [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.pointAddBtn.mas_bottom).offset(30);
            make.left.equalTo(self.ySlider);
        }];
        
        [self.clearBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.okBtn);
            make.left.equalTo(self.okBtn.mas_right).offset(20);
        }];
        
        // 赋值
        self.chartView.backgroundColor = UIColor.blueColor;
        
        self.xSlider.minimumValue = 0;
        self.xSlider.maximumValue = 100;
        [self.xAddBtn setTitle:@"+" forState:UIControlStateNormal];
        [self.xRemoveBtn setTitle:@"-" forState:UIControlStateNormal];
        self.xAddBtn.backgroundColor = UIColor.orangeColor;
        self.xRemoveBtn.backgroundColor = UIColor.orangeColor;
        
        self.ySlider.minimumValue = 0;
        self.ySlider.maximumValue = 100;
        [self.yAddBtn setTitle:@"+" forState:UIControlStateNormal];
        [self.yRemoveBtn setTitle:@"-" forState:UIControlStateNormal];
        self.yAddBtn.backgroundColor = UIColor.orangeColor;
        self.yRemoveBtn.backgroundColor = UIColor.orangeColor;
        
        [self.pointAddBtn setTitle:@"添加" forState:UIControlStateNormal];
        [self.pointRemoveBtn setTitle:@"删除" forState:UIControlStateNormal];
        self.pointAddBtn.backgroundColor = UIColor.orangeColor;
        self.pointRemoveBtn.backgroundColor = UIColor.orangeColor;
        
        [self.selectPreBtn setTitle:@"选上一个" forState:UIControlStateNormal];
        [self.selectNextBtn setTitle:@"选下一个" forState:UIControlStateNormal];
        self.selectPreBtn.backgroundColor = UIColor.orangeColor;
        self.selectNextBtn.backgroundColor = UIColor.orangeColor;
        
        [self.okBtn setTitle:@"OK" forState:UIControlStateNormal];
        [self.clearBtn setTitle:@"Cancel" forState:UIControlStateNormal];
        self.okBtn.backgroundColor = UIColor.orangeColor;
        self.clearBtn.backgroundColor = UIColor.orangeColor;
    }
    return self;
}


@end
